#include <iostream>
#include <algorithm>
using namespace std;


int main()
{
	char nums[] = "0123456789";
	for (unsigned int i = 1; i != 1000000; i++)
		next_permutation(nums, nums+sizeof(nums)-1);

	cout << nums << endl;
	return 0;
}
